﻿namespace REVISIONMAX20
{
    using System;
    using System.ComponentModel;
    using System.Data.SQLite;
    using System.Drawing;
    using System.Windows.Forms;
    using WeifenLuo.WinFormsUI.Docking;

    public class frmMain : Form
    {
        private ToolStripButton btnRefresh;
        private ToolStripButton btnShowGroups;
        private IContainer components = null;
        private DockPanel dpMainMdi;
        private ToolStrip toolStrip1;
        private ToolStripButton toolStripButton1;
        private ToolStripButton toolStripButton2;
        private ToolStripSeparator toolStripSeparator1;
        private ToolStripSeparator toolStripSeparator2;
        private UIHandler uiHandler = null;

        public frmMain()
        {
            this.InitializeComponent();
        }

        private void btnShowGroups_Click(object sender, EventArgs e)
        {
            this.uiHandler.ShowGroups();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void frmMain_Load(object sender, EventArgs e)
        {
            this.uiHandler = new UIHandler(this.dpMainMdi);
        }

        private void InitializeComponent()
        {
            this.toolStrip1 = new System.Windows.Forms.ToolStrip();
            this.btnRefresh = new System.Windows.Forms.ToolStripButton();
            this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
            this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
            this.toolStripButton2 = new System.Windows.Forms.ToolStripButton();
            this.btnShowGroups = new System.Windows.Forms.ToolStripButton();
            this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
            this.dpMainMdi = new WeifenLuo.WinFormsUI.Docking.DockPanel();
            this.toolStrip1.SuspendLayout();
            this.SuspendLayout();
            // 
            // toolStrip1
            // 
            this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.btnRefresh,
            this.toolStripSeparator2,
            this.toolStripButton1,
            this.toolStripButton2,
            this.btnShowGroups,
            this.toolStripSeparator1});
            this.toolStrip1.Location = new System.Drawing.Point(0, 0);
            this.toolStrip1.Name = "toolStrip1";
            this.toolStrip1.Size = new System.Drawing.Size(712, 25);
            this.toolStrip1.TabIndex = 1;
            this.toolStrip1.Text = "toolStrip1";
            // 
            // btnRefresh
            // 
            this.btnRefresh.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
            this.btnRefresh.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.btnRefresh.Name = "btnRefresh";
            this.btnRefresh.Size = new System.Drawing.Size(49, 22);
            this.btnRefresh.Text = "Refresh";
            this.btnRefresh.Visible = false;
            // 
            // toolStripSeparator2
            // 
            this.toolStripSeparator2.Name = "toolStripSeparator2";
            this.toolStripSeparator2.Size = new System.Drawing.Size(6, 25);
            this.toolStripSeparator2.Visible = false;
            // 
            // toolStripButton1
            // 
            this.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
            this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton1.Name = "toolStripButton1";
            this.toolStripButton1.Size = new System.Drawing.Size(23, 22);
            this.toolStripButton1.Text = "toolStripButton1";
            this.toolStripButton1.Click += new System.EventHandler(this.toolStripButton1_Click);
            // 
            // toolStripButton2
            // 
            this.toolStripButton2.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
            this.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton2.Name = "toolStripButton2";
            this.toolStripButton2.Size = new System.Drawing.Size(23, 22);
            this.toolStripButton2.Text = "toolStripButton2";
            this.toolStripButton2.Visible = false;
            this.toolStripButton2.Click += new System.EventHandler(this.toolStripButton2_Click);
            // 
            // btnShowGroups
            // 
            this.btnShowGroups.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
            this.btnShowGroups.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.btnShowGroups.Name = "btnShowGroups";
            this.btnShowGroups.Size = new System.Drawing.Size(74, 22);
            this.btnShowGroups.Text = "Show Groups";
            this.btnShowGroups.Click += new System.EventHandler(this.btnShowGroups_Click);
            // 
            // toolStripSeparator1
            // 
            this.toolStripSeparator1.Name = "toolStripSeparator1";
            this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25);
            // 
            // dpMainMdi
            // 
            this.dpMainMdi.ActiveAutoHideContent = null;
            this.dpMainMdi.Dock = System.Windows.Forms.DockStyle.Fill;
            this.dpMainMdi.Location = new System.Drawing.Point(0, 25);
            this.dpMainMdi.Name = "dpMainMdi";
            this.dpMainMdi.Size = new System.Drawing.Size(712, 420);
            this.dpMainMdi.TabIndex = 8;
            // 
            // frmMain
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(712, 445);
            this.Controls.Add(this.dpMainMdi);
            this.Controls.Add(this.toolStrip1);
            this.IsMdiContainer = true;
            this.Name = "frmMain";
            this.Text = "REVISIONMAX20";
            this.Load += new System.EventHandler(this.frmMain_Load);
            this.toolStrip1.ResumeLayout(false);
            this.toolStrip1.PerformLayout();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            MessageBox.Show(string.Format("{0:00}", 1));
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            using (SQLiteConnection connection = Common.GetSQLiteConnection())
            {
                connection.Open();
                using (SQLiteCommand command = connection.CreateCommand())
                {
                    command.CommandText = "select `id`, `source` from `sqlitems` where `sourcetype` = 'sqlfile'";
                    using (SQLiteDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            int num = reader.GetInt32(0);
                            string pValue = reader.GetValue(1).StringValueOrEmpty().Replace(@"H:\", @"\\mike01\(H) STORAGE\");
                            using (SQLiteCommand command2 = connection.CreateCommand())
                            {
                                command2.CommandText = string.Format("update `sqlitems` set `source` = {0} where `id` = {1}", pValue.DBString(), num);
                                command2.ExecuteNonQuery();
                            }
                        }
                    }
                }
            }
        }
    }
}

